#include"Teacher.h"
#include"Student.h"
#include<stdio.h>
#include<string.h>
void InitTeacher(teach *t, const char *name,int age)
{
    strcpy(t->Name, name);
    t->age = age;
    t->size = 0;
}


void PrintTeacher(teach *t)
{
    printf("姓名：%s 年龄：%d \n",t->Name,t->age);
    for (int i = 0; i < t->size;i++)
    {
        PrintStu(t->s + i);
    }
}
void InsertStu(teach *t,const char* name,int id,int age,double score)
{
    SetStuValue(&t->s[t->size], name, id, age, score);
    t->size++;
}

void RemoveByIndex(teach *t, int index)
{
    for (int i = index; i < t->size - 1;i++)
    {
        t->s[i] = t->s[i + 1];
    }
    t->size--;
}

void RemoveStu(teach *t, const char *name)
{
    for (int i = 0; i < t->size; i++)
    {
    if(strcmp(t->s[i].Name,name)==0)
    {
        RemoveByIndex(t, i);
        i--;
    }
    }
}

Stu *FindStu(teach *t, void *value,bool (*p)(Stu*,void*))
{
    for (int i = 0; i < t->size;i++)
    {
      if(p(&t->s[i],value)==true)
      {
        return &t->s[i];
      }
    }
    return NULL;
}
